# Table D2: Covid-19 Unemployment Effects on Asian Hate Crimes: Continuous Treatment Measure

rm(list = ls())

setwd('/path/to/replication/')

library(data.table)
library(estimatr)
library(texreg)

if (!file.exists('./output/out_econ_simple_cont.RData') &
    !file.exists('./output/out_econ_cont.RData') &
    !file.exists('./output/out_econ_con_cont.RData') &
    !file.exists('./output/out_econ_con_trend_all_cont.RData')) {
  source('./code/tableD2reg.R')
}

out_econ_simple <- get(load('./output/out_econ_simple_cont.RData'))
out_econ <- get(load('./output/out_econ_cont.RData'))
out_econ_con <- get(load('./output/out_econ_con_cont.RData'))
out_econ_con_trend_all <- get(load('./output/out_econ_con_trend_all_cont.RData'))

tabled2 <- texreg(list(out_econ_simple, out_econ, out_econ_con, out_econ_con_trend_all),
       include.ci = FALSE,
       include.adjrs = FALSE, include.rmse = FALSE,
       stars = c(0.001, 0.01, 0.05, 0.1), digits = 5,
       custom.coef.map = list('workers_losing_income_share' = 'Expected unemployment', 'covid2'= 'After Jan, 2020', 
                              'covid2:workers_losing_income_share' = 'After Jan, 2020 x Expected unemployment',
                              'covid_econ_cont' = 'After Jan, 2020 x Expected unemployment'),
       symbol = "\\circ",
       caption = "Covid-19 Unemployment Effects on Asian Hate Crimes: Continuous Treatment Measure",
       caption.above = TRUE)

write(tabled2, file.path('./tableD2.tex'))
